// components/goods-diy/youhui/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    coupon_list: {
      type: Object,
      value: null
    },
    __wxapp_img: {
      type: Object,
      value: null
    },
    __user_info: {
      type: Object,
      value: null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },
  ready: function () {
    
  },

  /**
   * 组件的方法列表
   */
  methods: {
    
    updateCoupon: function () {
      this.triggerEvent('updateCoupon')
    },
    receive: function(t) {
      var o = this, e = t.target.dataset.id,index= t.target.dataset.index;
      getApp().core.showLoading({
          mask: !0
      }), getApp().request({
          url: getApp().api.coupon.receive,
          data: {
              id: e
          },
          success: function(t) {
            if (t.code == 0) {
              var coupon_list = o.data.coupon_list;
              coupon_list[index].is_receive = 1;
              o.setData({
                coupon_list: coupon_list
              });
            }else {
              getApp().core.showModal({
                title: "提示",
                content: t.msg
              })
            }
          },
          complete: function() {
              getApp().core.hideLoading();
          }
      });
  },
  }
})
